/** 系统管理路由 */
import Layout from '@/views/layout/AdminLayout'

const layout = function (meta = {}, path = '/manage', requiresAuth = true) {
  return {
    path: path,
    component: Layout,
    meta: {
      requiresAuth: requiresAuth,
      ...meta
    }
  }
}

export default [

  // {
  //   ...layout({
  //     permissions: ['manage']
  //   }),
  //   children: [{
  //     path: 'update', // 升级
  //     component: () => import('@/views/admin/update'),
  //     meta: {
  //       title: '在线升级',
  //       icon: 'data-import'
  //     }
  //   }]
  // },
  {
    ...layout({
      permissions: ['manage', 'users', 'read']
    }),
    children: [{
      name: 'employee-dep',
      path: 'employee-dep', // 员工与
      component: () => import('@/views/admin/employeeDep'),
      meta: {
        title: '员工与部门管理',
        icon: 'employee'
      }
    }]
  },
  {
    ...layout({
      permissions: ['manage', 'permission'],
    }),
    children: [{
      name: 'role-auth',
      path: 'role-auth',
      component: () => import('@/views/admin/roleAuth/index'),
      meta: {
        title: '角色管理',
        icon: 'role'
      }
    }]
  },
  {
    ...layout({
      permissions: ['manage', 'crm'],
      title: '业务设置',
      icon: 'business'
    }, '/manage/business'),
    alwaysShow: true,
    children: [
      {
        name: 'custom-field',
        path: 'custom-field',
        component: () => import('@/views/admin/crm/customField'),
        meta: {
          title: '自定义字段设置',
          requiresAuth: true,
          permissions: ['manage', 'crm', 'field']
        }
      },
      {
        name: 'handlefield',
        path: 'custom-field/:type/:id/:label/',
        component: () => import('@/views/admin/crm/HandleField'),
        hidden: true,
        meta: {
          activeMenu: '/manage/customer/custom-field',
          requiresAuth: true,
          permissionList: [['manage', 'crm', 'field'], ['manage', 'crm', 'activityForm']]
        }
      },
      {
        name: 'handlefieldEdit',
        path: 'custom-field/:type/:id/:label/:index/:formType',
        component: () => import('@/views/admin/crm/HandleField'),
        hidden: true,
        meta: {
          activeMenu: '/manage/customer/custom-field',
          requiresAuth: true,
          permissionList: [['manage', 'crm', 'field'], ['manage', 'crm', 'activityForm']]
        }
      },
      {
        name: 'handleAllocation',
        path: 'fieldAllocation/:label',
        component: () => import('@/views/admin/crm/customField/handleAllocation'),
        hidden: true,
      }, {
        path: 'training-config',
        component: () => import('@/views/admin/trainingConfig/index'),
        meta: {
          title: '训练营模式',
          requiresAuth: true,
          permissions: ['manage', 'crm', 'training']
        }
      }]
  },
  {
    ...layout({
      permissions: ['manage', 'examineFlow', 'update'],
      title: '工作流配置',
      icon: 'pool'
    }),
    children: [{
      name: 'system-examine',
      path: 'system-examine', // 审批列表
      component: () => import('@/views/admin/examine'),
      meta: {
        title: '工作流配置',
        requiresAuth: true,
      }
    }, {
      name: 'examineCreate',
      path: 'system-examine-create/:type/:examineId', // 新建审批
      component: () => import('@/views/admin/examine/Create'),
      hidden: true,
      meta: {
        title: '创建审批',
        activeMenu: '/manage/system-examine',
      },
    },
    {
      name: 'examineEdit',
      path: 'system-examine-edit/:type/:examineId', // 编辑审批
      component: () => import('@/views/admin/examine/Create'),
      hidden: true,
      meta: {
        title: '编辑审批',
        icon: 'approve'
      }
    }]
  },
  // {
  //   ...layout(),
  //   hidden: true,
  //   children: [{
  //     name: 'examineCreate',
  //     path: 'system-examine/:create', // 新建审批
  //     component: () => import('@/views/admin/examine/Create'),
  //     // hidden: true,
  //     meta: {
  //       title: '创建审批',
  //       icon: 'approve'
  //     }
  //   },
  //   {
  //     name: 'examineEdit',
  //     path: 'system-examine-edit/:edit', // 编辑审批
  //     component: () => import('@/views/admin/examine/Create'),
  //     hidden: true,
  //     meta: {
  //       title: '编辑审批',
  //       icon: 'approve'
  //     }
  //   }]
  // },
  // {
  //   ...layout({
  //     permissions: ['manage', 'oa']
  //   }),
  //   children: [{
  //     name: 'system-workbench',
  //     path: 'system-workbench', // 办公审批流
  //     component: () => import('@/views/admin/oa'),
  //     meta: {
  //       title: '办公审批流',
  //       icon: 'approve'
  //     }
  //   }, {
  //     name: 'workbenchHandlefield',
  //     path: 'workbench-custom-field/:type/:id/:label',
  //     component: () => import('@/views/admin/crm/HandleField'),
  //     hidden: true,
  //     meta: {
  //       activeMenu: '/manage/system-workbench'
  //     }
  //   }]
  // },
  // {
  //   ...layout({
  //     permissions: ['manage', 'work']
  //   }),
  //   children: [{
  //     name: 'system-project',
  //     path: 'system-project', // 项目管理
  //     component: () => import('@/views/admin/project'),
  //     meta: {
  //       title: '项目管理',
  //       icon: 'project'
  //     }
  //   }]
  // },
  // {
  //   ...layout({
  //     //permissions: ['manage', 'adminLog'],
  //     permissions: ['manage', 'crm'],
  //     title: '学员管理',
  //     icon: 'customer'
  //   }, '/manage/customer'),
  //   alwaysShow: true,
  //   children: [

  //     {
  //       path: 'customer',
  //       component: () => import('@/views/admin/crm/customer'),
  //       meta: {
  //         title: '学员公海规则设置',
  //         requiresAuth: true,
  //         permissions: ['manage', 'crm', 'pool']
  //       }
  //     }, {
  //       path: 'print-templates',
  //       component: () => import('@/views/admin/crm/printTemplates'),
  //       meta: {
  //         title: '自定义打印模板',
  //         requiresAuth: true,
  //         permissions: ['manage', 'crm', 'print']
  //       }
  //     }, {
  //       path: 'print-detail',
  //       name: 'crmPrintDetail',
  //       component: () => import('@/views/admin/crm/printTemplates/PrintTemplateDetail'),
  //       hidden: true,
  //       meta: {
  //         activeMenu: '/manage/customer/print-templates',
  //         title: '自定义打印模板',
  //         requiresAuth: true,
  //         permissions: ['manage', 'crm', 'print']
  //       }
  //     },
  //     // {
  //     //   path: 'biz-param',
  //     //   component: () => import('@/views/admin/crm/bizParam'),
  //     //   meta: {
  //     //     title: '业务参数设置',
  //     //     requiresAuth: true,
  //     //     permissions: ['manage', 'crm', 'setting']
  //     //   }
  //     // },
  //     {
  //       name: 'crmBizGoals',
  //       path: 'biz-goals',
  //       component: () => import('@/views/admin/crm/bizGoals'),
  //       meta: {
  //         title: '业绩目标设置',
  //         requiresAuth: true,
  //         permissions: ['manage', 'crm', 'achievement']
  //       }
  //     },]
  // },
  // {
  //   ...layout({}, '/manage', false),
  //   children: [{
  //     name: 'system-other',
  //     path: 'system-other', // 其他配置
  //     component: () => import('@/views/admin/other'),
  //     meta: {
  //       title: '其他设置',
  //       icon: 'manage'
  //     }
  //   }]
  // },
  {
    ...layout({
      permissions: ['manage', 'system'],
      title: '商户配置',
      icon: 'merchant'
    }, '/manage/merchant'),
    alwaysShow: true,
    children: [{
      path: 'style-config',
      component: () => import('@/views/admin/merchant/styleConfig'),
      meta: {
        title: '样式配置',
        requiresAuth: true,
        permissions: ['manage', 'system', 'style']
      }
    }, {
      path: 'menu-config',
      component: () => import('@/views/admin/merchant/menuConfig'),
      meta: {
        title: '菜单配置',
        requiresAuth: true,
        permissions: ['manage', 'system', 'menuOpen']
      }
    }]
  },
  {
    ...layout({
      permissions: ['manage', 'adminLog'],
      title: '系统日志',
      icon: 'log'
    }, '/manage/log'),
    alwaysShow: true,
    children: [
      //   {
      //   path: 'handle',
      //   component: () => import('@/views/admin/log/DataHandleLog'),
      //   meta: {
      //     title: '数据操作日志',
      //     requiresAuth: true,
      //     permissions: ['manage', 'adminLog', 'actionRecord']
      //   }
      // },
      {
        path: 'sys',
        component: () => import('@/views/admin/log/SysHandleLog'),
        meta: {
          title: '操作日志',
          requiresAuth: true,
          permissions: ['manage', 'adminLog', 'systemLog']
        }
      }, {
        path: 'login',
        component: () => import('@/views/admin/log/LoginLog'),
        meta: {
          title: '登录日志',
          requiresAuth: true,
          permissions: ['manage', 'adminLog', 'loginLog']
        }
      }]
  },
  {
    ...layout({}, '/manage/msg/'),
    hidden: true,
    children: [{
      path: 'message', // 消息列表
      component: () => import('@/views/message/index'),
      meta: {
        title: '消息',
        icon: 'refund'
      }
    }]
  },
  {
    ...layout({
      permissions: ['address', 'addressBook','list'],
    }, '/manage/addressBooks/'),
    hidden: true,
    children: [{
      path: 'addressBooks',
      component: () => import('@/views/addressBooks/index'),
      meta: {
        title: '企业通讯录',
        icon: 'refund'
      }
    }]
  },
  {
    ...layout({}, '/manage/message'),
    hidden: true,
    children: [{
      path: 'message', // 待办事项
      component: () => import('@/views/crm/message'),
      meta: {
        title: '待办事项',
        icon: 'message',
      }
    }]
  },
  {
    ...layout({}, '/manage/person'),
    hidden: true,
    children: [{
      path: 'index',
      component: () => import('@/views/user/index'),
      meta: {
        title: '个人中心',
      }
    }]
  },
]
